<!DOCTYPE html>
<html>
<head>
    <title>首页 {$site_info.site_name|default=''}</title>
    <meta name="keywords" content="{$site_info.site_seo_keywords|default=''}"/>
    <meta name="description" content="{$site_info.site_seo_description|default=''}">
    <include file="public@head"/>
    <link href="__TMPL__/public/assets/css/slippry/slippry.css" rel="stylesheet">
    <link href="/static/js/layui/css/layui.css" rel="stylesheet">
    <hook name="before_head_end"/>
</head>
<body class="body-white">
<include file="public@nav"/>
<style>
    .posted {
        width: 80%;
        margin: 120px auto 0px;
    }

    .posted_h3 {
        font-size: 30px;
        font-weight: 500;
        color: #3c3c3c !important;
    }

    .posted_red {
        color: #f13636;
        height: 50px;
        line-height: 50px;
    }

    .posted_z {
        color: #f13636;
    }

    .posted_fb {
        border: 1px solid #ccc;
        min-height: 400px;
    }

    .btn-default {
        background-color: #28caad !important;
        border-color: #28caad !important;
    }

    .info {
        color: #FF7518 !important;
    }

    .container {
        width: 100% !important;
    }

    table .info a {
        color: #ff1616 !important;
        padding: 10px;
    }

    #success div {
        text-align: center !important;
    }
    .footer-p{
        width: 100%;
        position: fixed;
        bottom: 0;
    }
</style>
<div class="posted">
    <h3 class="posted_h3">发布内测分发应用</h3>
    <div class="posted_red">{$config.system_message}
    </div>
    <div class="posted_fb">
        <div class="container" style="padding-top: 60px;">
            <div class="tab-content">
                <div role="tabpanel" style="margin: auto" class="tab-pane fade in active" id="demo"
                     aria-labelledby="demo-tab">

                    <div class="row" style="margin-top: 20px;">
                        <input type="hidden" id="posted" value="{:cmf_url('user/profile/add_qiniu')}">
                        <input type="hidden" id="domain" value="http://{$data.data.domain}/">
                        <input type="hidden" id="uptoken_url" value="{$data.uptoken_url}">
                        <input type="hidden" id="bundle" value="{$data.bundle}">
                        <div class="col-sm-2 col-sm-offset-5">
                            <div id="container">
                                <a class="btn btn-default btn-lg " id="pickfiles" href="#">
                                    <span> 选择文件</span>
                                </a>
                            </div>
                        </div>
                        <div class="col-md-12" style="text-align:center;" id="details">
                            <div> 您所在会员组剩余可上传 {$config.app_file_max_size} MB，超过此额度的应用将上传失败【联系客服：{$config.service_qq}】</div>
                            <div>（支持.ipa或.apk文件，不支持IE与safari浏览器）</div>
                        </div>
                        <div style="display:none" id="success" class="col-md-12">
                            <div class="alert-success">
                                队列全部文件处理完毕
                            </div>
                        </div>
                        <div class="col-md-12 ">
                            <table class="table table-striped table-hover text-left"
                                   style="margin-top:40px;display:none">
                                <thead>
                                <tr>
                                    <th class="col-md-4">文件</th>
                                    <th class="col-md-2">大小</th>
                                    <th class="col-md-6">上传进度</th>
                                </tr>
                                </thead>
                                <tbody id="fsUploadProgress">
                                </tbody>
                            </table>
                        </div>
                    </div>

                </div>

            </div>
        </div>

    </div>
</div>
<div class="footer-p">
   <include file="public@footer"/> 
</div>

<include file="public@scripts"/>

</body>
<script src="/static/js/layui/layui.all.js"></script>
<script src="/dist/app-info-parser.js"></script>

<!--七牛js-->
<script src="/themes/simpleboot3/public/assets/qiniu_sdk/highlight.js"></script>
<!-- <script src="/themes/simpleboot3/public/assets/qiniu_sdk/main.js"></script> -->
<script src="/themes/simpleboot3/public/assets/qiniu_sdk/dist/qiniu.min.js"></script>
<script src="/themes/simpleboot3/public/assets/qiniu_sdk/ui.js"></script>
<script src="/themes/simpleboot3/public/assets/qiniu_sdk/main.js"></script>

<script src="/static/js/zipjs/zip.js"></script>
<script src="/static/js/base.js"></script>
<script src="/static/js/base64.min.js"></script>
<script type="text/javascript">
    var server = "http://{$data.data.domain}/";
    zip.workerScripts = {
        deflater: ['/static/js/zipjs/z-worker.js', '/static/js/zipjs/deflate.js'],
        inflater: ['/static/js/zipjs/z-worker.js', '/static/js/zipjs/inflate.js']
    };

    var config = {
        'file_size':{$config.app_file_max_size},
    };

    var appInfo;

    function fileSelect() {
        const files = document.getElementsByName('file')[0].files;

        var re = /.*\.ipa$/gi;
        var reApk = /.*\.apk$/gi;
        if(!re.test(files[0].name) && !reApk.test(files[0].name)){
            return;
        }

        const parser = new AppInfoParser(files[0])
        parser.parse().then(result => {
            appInfo = result;
            console.log('app info ----> ', result)
            console.log('icon base64 ----> ', result.icon)
        }).catch(err => {
            console.log('err ----> ', err)
        })
    }
</script>
</html>
